#include "stdafx.h"

#include <stdio.h>
#include <time.h>
#include <string.h>
#include <iostream>

#include <fcntl.h>
#include <errno.h>
#include <assert.h>
#include <signal.h>

#include <vector>
#include<sys/stat.h> 
#include <sys/types.h>

 
#include <sys/types.h>
#include <sys/stat.h>
 
#include <string.h>

using namespace std;

#include "../../../include/fore/fore_rtdb.h"
#include "../../../include/common/base.h"


#ifndef WIN32 
	#include <unistd.h>
	#include <netdb.h>
	#include <stdio.h> 
	#include <stdlib.h>  
	#include <linux/types.h> 
	#include <string.h> 
	#include <sys/socket.h> 
	#include <netinet/in.h> 
	#include <net/if.h> 
	#include <netdb.h> 
	#include <arpa/inet.h> 
	#include <sys/ioctl.h>
#else
	#include <Windows.h>
    
#endif


//#include "../../../include/cac/fore_pubNet.h"
#include "../../../include/fore/fore_rtdb.h"
 
#include "../../../include/rtdbms/rtdbFun.h"
  
/*int TForeSystemApp::GetProtocolID()
{	
	int protocol_id = -1;
  
	string  process_name =  base::GetCurrentProcessName();
	
	base::my_printf("process_name=%s \n", process_name.c_str() );

 	tHandle handle = OpenLib(FORE_PROTOCOL_NO);
	if( !IsHandleValid(handle) ) return -1;

	int ProcessId;
	
#ifdef WIN32
	ProcessId = GetCurrentProcessId();
#else
	ProcessId = getpid();
#endif

	FORE_PROTOCOL process;
	bool ret = ReadFirst(handle, (char*)&process, sizeof(FORE_PROTOCOL));

	while( ret )
	{ 
		if( process.IsValid() )
		{ 
			if( strcmp(process_name.c_str(), process.process_name ) == 0 )
			{
				protocol_id = process.ProtocolId;
				break;
			} 
			else {
				base::my_printf("process_name=%s, rtdb_process_name=%s\n", process_name.c_str(), process.process_name);
			}
		} 
		else {
			base::my_printf("process.IsValid()  process_name=%s, rtdb_process_name=%s \n", process_name.c_str(), process.process_name);
		}
	
		ret = ReadNext(handle, (char*)&process, sizeof(FORE_PROTOCOL));
	}

	CloseLib(handle); 

	return protocol_id;
}*/
 
